hvmloader: use bound checking in get_module_entry
authorWei Liu <wei.liu2@citrix.com>
Mon, 22 Aug 2016 12:47:53 +0000 (13:47 +0100)
committerWei Liu <wei.liu2@citrix.com>
Mon, 22 Aug 2016 13:20:19 +0000 (14:20 +0100)
commit94d3b9990bf73459919fb5b234d088d1ac41c9da
tree08c1e9d0ef7ef3b725e32bc1146048880b6f80f1
parent80a59905fd36cc1625cf0e4d128bd764ecea3aca
hvmloader: use bound checking in get_module_entry

Coverity complains:

overflow_before_widen: Potentially overflowing expression
info->nr_modules * 32U with type unsigned int (32 bits, unsigned) is
evaluated using 32-bit arithmetic, and then used in a context that
expects an expression of type uint64_t (64 bits, unsigned).

The overflow is unlikely to happen in reality because we only expect a
few modules.

Fix that by converting the check to use bound checking to placate
Coverity.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
tools/firmware/hvmloader/hvmloader.c